<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
		<meta http-equiv="Pragma" content="no-cache" />
		<meta http-equiv="Expires" content="0" />
		<title>卖家中心</title>
		<link rel="stylesheet" href="../css/common.css">
		<link rel="stylesheet" href="../css/my.css">
		<script src="../js/jquery-3.2.1.min.js"></script>
		<script src="../js/media.js"></script>
		<script src="../js/common.js"></script>
		<style>
			.public-header {
				background: rgba(95, 49, 4, 1);
			}
			
			.public-header-center {
				color: #fff !important;
			}
			#info_page li{
				position:relative;
			}
			.red_num{
				display: inline-block;
				position:absolute;
				top:-5px;
				right:-5px;
				width:20px;
				height:20px;
				border-radius:20px;
				background:red;
				text-align: center;
				line-height: 20px;
				font-size:0.1rem;
				color:#fff;
				visibility: hidden;
			}
		</style>
	</head>

	<body>
		<!--头部-->
		<div class="public-header flex">
			<!--<span class="public-header-left-search"></span>-->
			<!--<span class="public-header-left-back"></span>-->
			<span class="public-header-center" style="background:url(../img/切换@2x.png) no-repeat 2.16rem;background-size:.1rem .13rem;" onclick="javascript:window.location.href='../wode/my-page.html'">卖家中心</span>
			<span class="public-header-right"></span>
		</div>

		<!--正文-->
		<div class="Sellers-center bc-gray" style="padding-bottom:8vw;">
			<div class="section1">
				<div style="position: absolute;width: 100%;top: 40px;">
					<div style="position: relative;width: 0.64rem;height: 0.64rem;margin: 0 auto;">
						<img id="store_img" style="padding-top: 0;border-radius: 100px;" src="../img/ZitaohuiLogo.png" alt="">
						<img style="display: none;width: 0.15rem;height:0.15rem;position: absolute;right: -10px;bottom: 0;padding: 0;margin: 0;" id="qy_or_gr" src="../img/qiye.png" />
					</div>
					<p class="t1">
						<span>这里是昵称</span>
						<em></em>
						<i><font id="lever"></font></i>
					</p>
					<p class="t2">粉丝:<span id="fans"></span></p>
				</div>

				<div class="box flex">
					<div class="left" onclick="isallow('../wode/out_home.html')">
						<span></span>
						<p>账户</p>
					</div>
					<!--                <div class="right" onclick="javascript:window.location.href='../page/message.html'">
                    <span></span>
                    <p>消息</p>
                </div>-->
				</div>
			</div>
			<span style="display:block;height:40px;background:#fff;"></span>
			<div class="section2">
				<div class="top flex">
					<span>我的订单</span>
					<span><a onclick="isallow('../page/Seller-order.html?tab_num=0')">全部</a></span>
				</div>
				<ul class="flex bottom" id="info_page">
					<li data-tab='1' class="money_hu">
						<img src="../img/付款@2x.png" alt="">
						<p>未付款</p>
						<span class="red_num goods_nums_nomoney"></span>
					</li>
					<li data-tab='2' class="money_hu">
						<img src="../img/发货@2x.png" alt="">
						<p>待发货</p>
						<span class="red_num goods_nums_nogoods"></span>
					</li>
					<li data-tab='3' class="money_hu">
						<img src="../img/待收货@2x.png" alt="">
						<p>待收货</p>
						<span class="red_num goods_nums_daigoods"></span>
					</li>
					<li class="siren_d" onclick="isallow('../page/personalval.html?style=1')">
						<img src="../img/sirdz.png" alt="">
						<p>私人定制</p>
						<span class="red_num goods_nums_siren"></span>
					</li>
					<li onclick="isallow('../page/Shop-report.html')">
						<img src="../img/报表@2x.png" alt="">
						<p>店铺报表</p>
					</li>
					<li data-tab='4' class="money_hu">
						<img src="../img/售后@2x.png" alt="">
						<p>售后</p>
						<span class="red_num goods_nums_shouh"></span>
					</li>
				</ul>
			</div>
			<siv class="section3 clearfix">
				<ul>
					<li class="flex" onclick="isallow('../page/Lot-management.html')">
						<div class="left">
							<img src="../img/shangpin.png" alt="">
							<span class="span1">商品管理</span>
						</div>
						<em></em>
					</li>
					<li class="flex" onclick="isallow('../page/my_Lot-management.html')">
						<div class="left">
							<img src="../img/拍品管理@2x.png" alt="">
							<span class="span1">作品管理</span>
						</div>
						<em></em>
					</li>
					<li class="flex" onclick="isallow('../page/Promotion-center.html')">
						<div class="right">
							<img src="../img/推广@2x.png" alt="">
							<span class="span2">推广中心</span>
						</div>
						<em></em>
					</li>
					<!--             <li class="flex" onclick="javascript:window.location.href='../page/Send-a-message.html'">
                    <div class="left">
                        <img src="../img/消息@2x 2.png" alt="">
                        <span class="span3">群发消息</span>
                    </div>
                    <em></em>
                </li>-->
					<li class="flex" onclick="isallow('../page/Extended-service.html')">
						<div class="right">
							<img src="../img/服务@2x.png" alt="">
							<span class="span4">扩展服务</span>
						</div>
						<em></em>
					</li>
					<li class="flex" onclick="javascript:window.location.href='../page/setting-center.html'">
						<div class="left">
							<img src="../img/个人中心-设置@2x.png" alt="">
							<span class="span5">设置中心</span>
						</div>
						<em></em>
					</li>

				</ul>
			</siv>
		</div>

		<!--底部-->
		<div class="public-footer flex">
			<div class="button-1" onclick="javascript:window.location.href='../index.html'">
				<span></span>
				<p>首页</p>
			</div>
			<div class="button-2" onclick="javascript:window.location.href='../fenlei/fenlei.html'">
				<span></span>
				<p>分类</p>
			</div>
			<div class="button-3" onclick="javascript:window.location.href='../page/Excellent-shop.html'">
				<span></span>
				<p>店铺</p>
			</div>
			<div class="button-4 active">
				<span></span>
				<p>我的</p>
			</div>

		</div>
		<script>
			var allow = false; //是否通过企业验证的标识
			var isupmoney = false;
			var person_store = true;//个人店铺
			var is_son = getQueryString('is_son');//是否从子账号跳转过来的。如果是的话就不需要用userid来换取storeid了
			$("#store_img").click(function(){//点击头像，跳转到店铺的详情页面
				window.location.href = "../page/Shop.html"+"?s_id="+sessionStorage.s_id;
			});
			function storeInfo (){//拉取关于店铺的信息
				var storeid = sessionStorage.getItem('s_id');
				console.log(storeid);
				$.ajax({ //获取店铺的认证信息，如果没认证的话，就不能点击其他的页面了！
					url: base_url + 'ZITAOHUI/store/msg',
					data: {
						store_id: storeid
					},
					success: function(data) {
						//console.log(data);
						let all_data = data.extend.list;
						if(all_data.store_authority == 1) {
							$('#true_name').text('已审核');
							allow = 1; //认证成功
						} else if(all_data.store_authority == 22) {
							allow = 22; //店铺认证中
						} else if(all_data.store_authority == 21) {
							allow = 21; //个人认证中
						}
						if(all_data.store_amount_guaranteed == 0) {
							$('#amount').text('未缴纳');
							isupmoney = false;
						} else {
							$('#amount').text(all_data.store_amount_guaranteed);
							isupmoney = true;
						}
						if(is_son=='true'){
							$('.Sellers-center .section1 img').eq(0).attr('src','../img/子账号登录@2x.png' )//子账号的头像
							$('.Sellers-center .section1 .t1 span').html(all_data.store_name+"(子账号登录)");//名称
							$("#fans").text(data.extend.list.store_total_fans);//店铺的粉丝数
							$('#lever').text(all_data.store_level);//店铺等级
						}
						if(all_data.enterprise_name){//通过判断字符串的长度判断是个人店铺还是企业店铺！
							$('#true_name').text('企业店铺已审核');
							person_store = false;
						}else{
							$('#true_name').text('个人店铺已审核');
							person_store = true ;
						}
						
					}
				})
			}
			function isallow(urls) {//检验是否通过企业验证的函数，入参是如果验证成功后跳转的页面！
				if(allow == 1) {
					if(urls != "../page/Lot-management.html") { //不是产品管理的页面，验证通过以后就可以进入页面了
						window.location.href = urls;
					} else { //是产品管理的页面，需要再验证一个是否上传消保金
						if(isupmoney) {
							window.location.href = urls;
						} else {
							alert('请您先交纳消保金，方可上传产品');
							window.location.href = "../page/My-blessing.html?is_person_store="+person_store;
						}
					}

				} else if(allow == 22) {
					alert('店铺正在认证中,请稍后');
				} else if(allow == 21) {
					alert('店铺正在认证中,请稍后');
				} else {
					alert('请先进行个人或店铺认证');
					window.location.href = "../page/option_chose.html"; //跳转到个人/店铺认证页面
				}
			}

			$(function() {
				// 点击待付款等，进入相应的页面
				$('.money_hu').click(function() {
					if(allow == 1) {
						window.location.href = '../page/Seller-order.html?tab_num=' + $(this).data('tab');
					} else if(allow == 22) {
						alert('店铺正在认证中,请稍后');
					} else if(allow == 21) {
						alert('店铺正在认证中,请稍后');
					} else {
						alert('请先进行个人或店铺认证');
						window.location.href = "../page/option_chose.html"; //跳转到个人/店铺认证页面
					}
				})
				if(is_son=='true'){
					storeInfo();//获取到了需要管理店铺的信息
				}else{
					$.ajax({
						url: base_url + 'ZITAOHUI/user',
						type: 'get',
						data: {
							userId: sessionStorage.getItem("uid"),
							value: 1
						},
						success: function(data) {
							//console.log(data);
							let all_data = data.extend.user;
							//console.log(all_data)
							let user_nike_name = all_data.storeName;
							let user_type = all_data.storeLevel;
							let att_num = all_data.storeTotalFans;
							let img = all_data.storeImage==null?'../用户@3x.png':all_data.storeImage;
							// 获取storeid并存储在session里面
							let s_id = all_data.storeId;
							//console.error(s_id);
							$("#fans").text(all_data.storeTotalFans);
							window.sessionStorage.setItem('s_id', s_id);
							storeInfo();
							$('.Sellers-center .section1 img').eq(0).attr('src', img)
							$('.Sellers-center .section1 .t1 span').html(user_nike_name);
							//$('.Sellers-center .section1 .t1 i span').html(user_type);
							$('.Sellers-center .section1 .t2 font').html(att_num);
							$("#lever").text(user_type);
							console.log(all_data.enterpriseName);
							if(all_data.enterpriseName){//判断为个人店铺还是企业店铺
								//企业店铺
								$('#qy_or_gr').show();
							}else{
								
								$('#qy_or_gr').hide();
							}
						}
					})
				}
			});
            $.ajax({//买家中的产品订单状态数量
	            	url:base_url + 'ZITAOHUI/user/orderNum',
	            	type:'get',
	            	data:{
	            		storeId:sessionStorage.getItem('s_id'),
	            		userId:sessionStorage.getItem("uid"),
	            		identity:2,
	            	},
	            	success:function(data){
	            		var datas=  data.extend.num
					datas[1].user_order_num!=0?$('.goods_nums_nomoney').css('visibility','visible').text(datas[1].user_order_num):'';//待付款
					datas[2].user_order_num!=0?$('.goods_nums_nogoods').css('visibility','visible').text(datas[2].user_order_num):'';//待发货
	            		datas[3].user_order_num!=0?$('.goods_nums_daigoods').css('visibility','visible').text(datas[3].user_order_num):'';//待收货
	            		datas[5].user_order_num!=0?$('.goods_nums_shouh').css('visibility','visible').text(datas[5].user_order_num):'';//售后
	            	}
            });
            $.ajax({//买家中私人订制
	            	url:base_url + 'ZITAOHUI/selectCustomization',
	            	type:'get',
	            	data:{
	            		store_id:sessionStorage.getItem('s_id'),
	            		user_id:'',
	            		produce_id:'',
	            	},
	            	success:function(data){
	            		var datas=  data.extend.list
	            		datas.length!=0?$('.goods_nums_siren').css('visibility','visible').text(datas.length):'';//私人订制数量
	            	}
            })
		</script>

	</body>

</html>